<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // ES5写法
        var name = 'tom';
        var age = 10;
        var obj = {
            name:name,
            age:age
        }
        console.log(obj);

        // ES6写法,属性名和属性值一样时，对象属性简写
        var name = 'tom';
        var age = 11;
        var obj1 = {
            name,
            age
        }
        console.log(obj1);
        console.log('-----------------------');

        // ES5写法
        var name = 'tom';
        var age = 12;
        var obj2 = {
            name:name,
            age:age,
            sayAddress:function(){
                console.log('广西');
            }
        }
        // var re = obj2.sayAddress();
        // console.log(re,'===');
        console.log(obj2);
        console.log(obj2.sayAddress());
        console.log('-----------------------');


        // ES6写法,属性名和属性值一样时，对象方法的简写
        var name = 'tom';
        var age = 13;
        var obj3 = {
            name,
            age,
            sayAddress(){
                console.log('广西');
            }
        }
        // var re = obj2.sayAddress();
        // console.log(re,'===');

        console.log(obj3);
        console.log(obj3.sayAddress());
        console.log('-----------------------');
    </script>
</body>
</html>